package com.nondo.dean.dealer.service;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import com.nondo.dean.common.web.View;
import com.nondo.dean.dealer.model.SlideBean;

/**
 * 幻灯片管理业务类
 * 
 * @author zhaoljin
 * @date 2018年5月10日
 */
@Component
public class SlideService {

    @Autowired
    RestTemplate restTemplate;

    /**
     * 查询经销商首页放置的幻灯片
     * 
     * @return 幻灯片信息{@link SlideBean}
     */
    @SuppressWarnings("unchecked")
    public List<SlideBean> getSlideList() {
        List<SlideBean> slideList = new ArrayList<SlideBean>();
        View<LinkedHashMap<String, Object>> result =
            restTemplate.postForEntity("http://dean-platform/platform/v1/inner/slide/list/0", null, View.class)
                .getBody();
        if (result.getCode() == 20000 && result.getData() != null) {
            slideList = (List<SlideBean>)result.getData();
        }
        return slideList;
    }
}
